#!/bin/bash

# 安装依赖
echo "正在安装主应用依赖..."
cd main-app && npm install && cd ..

echo "正在安装子应用1依赖..."
cd vue2-sub-app1 && npm install && cd ..

echo "正在安装子应用2依赖..."
cd vue2-sub-app2 && npm install && cd ..

# 启动应用
echo "正在启动所有应用..."

# 启动主应用
cd main-app
npm run serve &
MAIN_PID=$!

# 启动子应用1
cd ../vue2-sub-app1
npm run serve &
SUB1_PID=$!

# 启动子应用2
cd ../vue2-sub-app2
npm run serve &
SUB2_PID=$!

# 等待用户输入
echo "所有应用已启动！"
echo "主应用运行在: http://localhost:8080"
echo "子应用1运行在: http://localhost:8081"
echo "子应用2运行在: http://localhost:8082"
echo "按 Ctrl+C 停止所有应用"

# 捕获 Ctrl+C 信号
trap "kill $MAIN_PID $SUB1_PID $SUB2_PID; exit" INT

# 保持脚本运行
wait 